package com.cykj.service.impl;

import com.cykj.mapper.FoodMapper;
import com.cykj.pojo.Food;
import com.cykj.pojo.Scenic;
import com.cykj.service.FoodService;
import com.cykj.util.PageResult;
import com.cykj.util.PageUtils;
import com.cykj.util.ResponseDto;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FoodServiceImpl implements FoodService {
    @Autowired
    private FoodMapper foodMapper;
    @Override
    public ResponseDto getFoods(int pageCurr, int pageSize) {
        Page<Object> page = PageHelper.startPage(pageCurr, pageSize);
        List<Food> foodList = foodMapper.getFoods();
        PageInfo<Object> pageInfo = new PageInfo<>(page);
        PageResult pageResult = PageUtils.getPageResult(pageInfo);
        return new ResponseDto(1,"查询成功",pageResult);
    }

    @Override
    public ResponseDto searchInfo(int pageCurr, int pageSize, String value) {
        Page<Object> page = PageHelper.startPage(pageCurr, pageSize);
        List<Food> foodList = foodMapper.searchInfo(value);
        PageInfo<Object> pageInfo = new PageInfo<>(page);
        PageResult pageResult = PageUtils.getPageResult(pageInfo);
        return new ResponseDto(1,"查询成功",pageResult);
    }
}
